package com.oitsm.plugin.entity;

import java.util.HashMap;
import java.util.Map;
/**
 * 采集上下文
 * @author Arab Runner
 * Jul 17, 2011 10:31:55 AM
 */
public class Context {
	/**
	 * 令牌,用于标示本次采集采集
	 */
	private String token;
	/**
	 * 上问下创建的时间
	 */
	private long createTime;
	
	/**
	 * 检测器参数
	 */
	private Map<String,String> props = null;
	
	/**
	 * 上下文属性
	 */
	private Map<String,Object> attrs =  new HashMap<String,Object>();
	
	public Context(Map<String,String> props){
		this.props = props;
	}
	
	public String getProp(String key){
		return props == null ? null : props.get(key);
	}
	
	public String getProp(String key,String defaultVal){
		String value = getProp(key);
		return value == null ? defaultVal : value;
	}
	
	public Object getAttr(String key){
		return attrs.get(key);
	}
	
	public String getStrAttr(String key){
		Object value = attrs.get(key);
		return value == null ? null : value.toString();
	}
	
	public void setAttr(String key,Object value){
		attrs.put(key, value);
	}

	public String getToken() {
		return token;
	}

	public long getCreateTime() {
		return createTime;
	}
}
